package junit.admin;

import com.jfinal.aop.Inject;
import io.jboot.test.MockMvcResult;
import io.jpress.service.UserService;
import junit.base.AdminBaseTester;
import org.junit.Assert;
import org.junit.Test;

public class AdminUserDetailTester extends AdminBaseTester {


    @Inject
    private UserService userService;


    @Test
    public void startRoleTestCases() {

        //用户登录，默认账号 admin 123456
        doLogin();

        //查看用户头像
        testVisitUserAvatarDetail();

        //查看用户联系信息
        testVisitUserCommunicationDetail();

        //查看用户详情信息，包含昵称，部门，注册时间等
        testVisitUserDetail();

        //查看用户角色信息
        testVisitUserRoleDetail();

        //查看用户签名信息
        testVisitUserSignatureDetail();

        //查看用户标签信息
        testVisitUserTagDetail();

        //查看用户操作记录
        testVisitUserUtmDetail();


    }


    /**
     * 查看用户详情
     */
    public void testVisitUserDetail() {
        Long userId = 1L;
        MockMvcResult mvcResult = mvc.get("/admin/user/detail/" + userId);

        Assert.assertTrue(mvcResult.getContent().contains("登录账号"));
        Assert.assertTrue(mvcResult.getContent().contains("所在部门"));
        Assert.assertTrue(mvcResult.getContent().contains("注册日期"));
    }

    /**
     * 查看用户角色详情
     */
    public void testVisitUserRoleDetail() {
        Long userId = 1L;
        MockMvcResult mvcResult = mvc.get("/admin/user/detail/role/" + userId);

        Assert.assertTrue(mvcResult.getContent().contains("用户角色"));
        Assert.assertTrue(mvcResult.getContent().contains("超级管理员"));
    }

    /**
     * 查看用户标签详情
     */
    public void testVisitUserTagDetail() {
        Long userId = 1L;
        MockMvcResult mvcResult = mvc.get("/admin/user/detail/tag/" + userId);

        Assert.assertTrue(mvcResult.getContent().contains("用户标签"));
        Assert.assertTrue(mvcResult.getContent().contains("tag"));

//        mvcResult.printResult();
    }




    /**
     * 查看用户联系信息
     */
    public void testVisitUserCommunicationDetail() {
        Long userId = 1L;
        MockMvcResult mvcResult = mvc.get("/admin/user/detail/communication/" + userId);

        Assert.assertTrue(mvcResult.getContent().contains("手机号"));
        Assert.assertTrue(mvcResult.getContent().contains("地址"));
        Assert.assertTrue(mvcResult.getContent().contains("邮编"));

//        mvcResult.printResult();
    }

    /**
     * 查看用户签名信息
     */
    public void testVisitUserSignatureDetail() {
        Long userId = 1L;
        MockMvcResult mvcResult = mvc.get("/admin/user/detail/signature/" + userId);

        Assert.assertTrue(mvcResult.getContent().contains("个人签名"));
        Assert.assertTrue(mvcResult.getContent().contains("写写现在的心情"));

//        mvcResult.printResult();
    }

    /**
     * 查看用户头像信息
     */
    public void testVisitUserAvatarDetail() {
        Long userId = 1L;
        MockMvcResult mvcResult = mvc.get("/admin/user/detail/avatar/" + userId);

        Assert.assertTrue(mvcResult.getContent().contains("选择图片"));
        Assert.assertTrue(mvcResult.getContent().contains("保存选择区域"));

//        mvcResult.printResult();
    }

    /**
     * 查看用户操作记录
     */
    public void testVisitUserUtmDetail() {
        Long userId = 1L;
        MockMvcResult mvcResult = mvc.get("/admin/user/detail/utm/" + userId);

        Assert.assertTrue(mvcResult.getContent().contains("路径"));
        Assert.assertTrue(mvcResult.getContent().contains("查询"));
        Assert.assertTrue(mvcResult.getContent().contains("渠道"));
        Assert.assertTrue(mvcResult.getContent().contains("媒介"));

//        mvcResult.printResult();
    }




}
